package nowcoder.hw.hj14;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
//        System.out.println("boot".compareTo("boat"));
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Integer n = Integer.valueOf(reader.readLine());
        String[] strings = new String[n];
        for (int i = 0; i < n; i++) {
            strings[i] = reader.readLine();
        }
        mySort(strings);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strings.length; i++) {
            sb.append(strings[i]).append("\n");
        }
        sb.deleteCharAt(sb.length() - 1);
        System.out.println(sb);
    }

    private static void mySort(String[] strings) {
//        Arrays.sort(strings);
        quickSort(strings, 0, strings.length - 1);
    }

    static void quickSort(String[] arr, int start, int end) {
        if (start >= end) return;
        int mid = start, left = start + 1, right = end;
        while (left <= right) {
            int compare = arr[left].compareTo(arr[mid]);
            if (compare > 0) {//left>mid，意思是left排右边
                String t = arr[right];
                arr[right] = arr[left];
                arr[left] = t;
                right--;
            } else if (compare <= 0) {//left<mid， a<b left在左边
                String t = arr[left];
                arr[left] = arr[mid];
                arr[mid] = t;
                mid = left;
                left++;

            }
        }
//       print(start,end,arr);
        quickSort(arr, start, mid - 1);
        quickSort(arr, mid + 1, end);


    }


    static void print(int start, int end, Object[] arr) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("start:").append(start).append("->end:").append(end);
        for (int i = start; i <= end; i++) {
            stringBuilder.append(" ").append(arr[i]);

        }
        System.out.println(stringBuilder);
    }
}
